/**
 * <copyright>
 * </copyright>
 *

 */
package br.ufrn.dimap.processDsl.impl;

import br.ufrn.dimap.processDsl.ArtifactElement;
import br.ufrn.dimap.processDsl.Discipline;
import br.ufrn.dimap.processDsl.ProcessDslPackage;
import br.ufrn.dimap.processDsl.RoleElement;
import br.ufrn.dimap.processDsl.Step;
import br.ufrn.dimap.processDsl.Task;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Task</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.TaskImpl#getName <em>Name</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.TaskImpl#getDescription <em>Description</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.TaskImpl#getDiscipline <em>Discipline</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.TaskImpl#getPurpose <em>Purpose</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.TaskImpl#getRolesElement <em>Roles Element</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.TaskImpl#getArtifactsElement <em>Artifacts Element</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.TaskImpl#getSteps <em>Steps</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TaskImpl extends MinimalEObjectImpl.Container implements Task
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDescription()
   * @generated
   * @ordered
   */
  protected static final String DESCRIPTION_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDescription()
   * @generated
   * @ordered
   */
  protected String description = DESCRIPTION_EDEFAULT;

  /**
   * The cached value of the '{@link #getDiscipline() <em>Discipline</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDiscipline()
   * @generated
   * @ordered
   */
  protected Discipline discipline;

  /**
   * The default value of the '{@link #getPurpose() <em>Purpose</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPurpose()
   * @generated
   * @ordered
   */
  protected static final String PURPOSE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getPurpose() <em>Purpose</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPurpose()
   * @generated
   * @ordered
   */
  protected String purpose = PURPOSE_EDEFAULT;

  /**
   * The cached value of the '{@link #getRolesElement() <em>Roles Element</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRolesElement()
   * @generated
   * @ordered
   */
  protected EList<RoleElement> rolesElement;

  /**
   * The cached value of the '{@link #getArtifactsElement() <em>Artifacts Element</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArtifactsElement()
   * @generated
   * @ordered
   */
  protected EList<ArtifactElement> artifactsElement;

  /**
   * The cached value of the '{@link #getSteps() <em>Steps</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSteps()
   * @generated
   * @ordered
   */
  protected EList<Step> steps;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected TaskImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return ProcessDslPackage.Literals.TASK;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ProcessDslPackage.TASK__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getDescription()
  {
    return description;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDescription(String newDescription)
  {
    String oldDescription = description;
    description = newDescription;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ProcessDslPackage.TASK__DESCRIPTION, oldDescription, description));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Discipline getDiscipline()
  {
    if (discipline != null && discipline.eIsProxy())
    {
      InternalEObject oldDiscipline = (InternalEObject)discipline;
      discipline = (Discipline)eResolveProxy(oldDiscipline);
      if (discipline != oldDiscipline)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, ProcessDslPackage.TASK__DISCIPLINE, oldDiscipline, discipline));
      }
    }
    return discipline;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Discipline basicGetDiscipline()
  {
    return discipline;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDiscipline(Discipline newDiscipline)
  {
    Discipline oldDiscipline = discipline;
    discipline = newDiscipline;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ProcessDslPackage.TASK__DISCIPLINE, oldDiscipline, discipline));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getPurpose()
  {
    return purpose;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPurpose(String newPurpose)
  {
    String oldPurpose = purpose;
    purpose = newPurpose;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ProcessDslPackage.TASK__PURPOSE, oldPurpose, purpose));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<RoleElement> getRolesElement()
  {
    if (rolesElement == null)
    {
      rolesElement = new EObjectContainmentEList<RoleElement>(RoleElement.class, this, ProcessDslPackage.TASK__ROLES_ELEMENT);
    }
    return rolesElement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ArtifactElement> getArtifactsElement()
  {
    if (artifactsElement == null)
    {
      artifactsElement = new EObjectContainmentEList<ArtifactElement>(ArtifactElement.class, this, ProcessDslPackage.TASK__ARTIFACTS_ELEMENT);
    }
    return artifactsElement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Step> getSteps()
  {
    if (steps == null)
    {
      steps = new EObjectContainmentEList<Step>(Step.class, this, ProcessDslPackage.TASK__STEPS);
    }
    return steps;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case ProcessDslPackage.TASK__ROLES_ELEMENT:
        return ((InternalEList<?>)getRolesElement()).basicRemove(otherEnd, msgs);
      case ProcessDslPackage.TASK__ARTIFACTS_ELEMENT:
        return ((InternalEList<?>)getArtifactsElement()).basicRemove(otherEnd, msgs);
      case ProcessDslPackage.TASK__STEPS:
        return ((InternalEList<?>)getSteps()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case ProcessDslPackage.TASK__NAME:
        return getName();
      case ProcessDslPackage.TASK__DESCRIPTION:
        return getDescription();
      case ProcessDslPackage.TASK__DISCIPLINE:
        if (resolve) return getDiscipline();
        return basicGetDiscipline();
      case ProcessDslPackage.TASK__PURPOSE:
        return getPurpose();
      case ProcessDslPackage.TASK__ROLES_ELEMENT:
        return getRolesElement();
      case ProcessDslPackage.TASK__ARTIFACTS_ELEMENT:
        return getArtifactsElement();
      case ProcessDslPackage.TASK__STEPS:
        return getSteps();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case ProcessDslPackage.TASK__NAME:
        setName((String)newValue);
        return;
      case ProcessDslPackage.TASK__DESCRIPTION:
        setDescription((String)newValue);
        return;
      case ProcessDslPackage.TASK__DISCIPLINE:
        setDiscipline((Discipline)newValue);
        return;
      case ProcessDslPackage.TASK__PURPOSE:
        setPurpose((String)newValue);
        return;
      case ProcessDslPackage.TASK__ROLES_ELEMENT:
        getRolesElement().clear();
        getRolesElement().addAll((Collection<? extends RoleElement>)newValue);
        return;
      case ProcessDslPackage.TASK__ARTIFACTS_ELEMENT:
        getArtifactsElement().clear();
        getArtifactsElement().addAll((Collection<? extends ArtifactElement>)newValue);
        return;
      case ProcessDslPackage.TASK__STEPS:
        getSteps().clear();
        getSteps().addAll((Collection<? extends Step>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case ProcessDslPackage.TASK__NAME:
        setName(NAME_EDEFAULT);
        return;
      case ProcessDslPackage.TASK__DESCRIPTION:
        setDescription(DESCRIPTION_EDEFAULT);
        return;
      case ProcessDslPackage.TASK__DISCIPLINE:
        setDiscipline((Discipline)null);
        return;
      case ProcessDslPackage.TASK__PURPOSE:
        setPurpose(PURPOSE_EDEFAULT);
        return;
      case ProcessDslPackage.TASK__ROLES_ELEMENT:
        getRolesElement().clear();
        return;
      case ProcessDslPackage.TASK__ARTIFACTS_ELEMENT:
        getArtifactsElement().clear();
        return;
      case ProcessDslPackage.TASK__STEPS:
        getSteps().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case ProcessDslPackage.TASK__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case ProcessDslPackage.TASK__DESCRIPTION:
        return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
      case ProcessDslPackage.TASK__DISCIPLINE:
        return discipline != null;
      case ProcessDslPackage.TASK__PURPOSE:
        return PURPOSE_EDEFAULT == null ? purpose != null : !PURPOSE_EDEFAULT.equals(purpose);
      case ProcessDslPackage.TASK__ROLES_ELEMENT:
        return rolesElement != null && !rolesElement.isEmpty();
      case ProcessDslPackage.TASK__ARTIFACTS_ELEMENT:
        return artifactsElement != null && !artifactsElement.isEmpty();
      case ProcessDslPackage.TASK__STEPS:
        return steps != null && !steps.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(", description: ");
    result.append(description);
    result.append(", purpose: ");
    result.append(purpose);
    result.append(')');
    return result.toString();
  }

} //TaskImpl
